<?php
namespace Home\Widget;
use Think\Controller;
class FeaturedWidget extends Controller{
	/**
	 * @param $name string 推荐产品的列表名称
	 *@param $template string 要使用的模板
	 */
	public function index($name,$template='featured'){
		$map=array(
			'code'	=>	'featured',
			'name'	=>	trim($name)
			);
		$module=M('Module')->where($map)->find();
		$module=json_decode($module['setting'],true);		
		$products=array();
		$ProductModel=D('Product');
		$products=$ProductModel->getSomeProducts($module['product']);
		$language_id=get_default_lng_id();
		$data=$module['module_description'][$language_id];
		$data['url']=U($module['link']);
		$this->assign('products',$products);
		$this->assign('data',$data);
		$this->display('Widget/' . $template);

	}
}